package Example10;

import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.LocalTime;
import java.time.format.DateTimeFormatter;

public class TestLocalDateAndTime {
    public static void main(String[] args) {
        LocalDate localDate=LocalDate.now();
        System.out.println("当前日期:"+localDate);

        LocalDateTime currentDateTime = LocalDateTime.now();
        System.out.println("当前日期时间:"+currentDateTime);

        int hour = currentDateTime.getHour();
        int minute = currentDateTime.getMinute();
        int second = currentDateTime.getSecond();
        System.out.println("提取出的小时："+hour);
        System.out.println("提取出的分钟："+minute);
        System.out.println("提取出的秒："+second);

    //    自己手动初始化时间
        LocalDateTime futureTime = LocalDateTime.of(2020, 11, 11, 11, 11, 11);
        System.out.println("今年的光棍节的日期是:"+futureTime);

        LocalDateTime futureTimeSub1 = futureTime.plusDays(-1);
        System.out.println("光棍节的前一天是:"+futureTimeSub1);


    }
}
